package com.itcast.ui;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

import com.itcast.logic.IWeiboActivity;

public class MainActivity extends TabActivity implements IWeiboActivity{
   public TabHost tmh ;
   private static String TAB_HOME = "TabHome";
   private static String TAB_MSG= "TabMSG";
   private RadioGroup radioGroup ;
	@Override
	public void init() {
		
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		super.setContentView(R.layout.maintabs);
		radioGroup = (RadioGroup)findViewById(R.id.main_radio);
		tmh = this.getTabHost();
		TabSpec ts1 = tmh.newTabSpec(TAB_HOME).setIndicator(TAB_HOME);
		ts1.setContent(new Intent(MainActivity.this , HomeActivity.class));
		tmh.addTab(ts1);
		TabSpec ts2 = tmh.newTabSpec(TAB_MSG).setIndicator(TAB_MSG);
		ts2.setContent(new Intent(MainActivity.this , MSGActivity.class));
		tmh.addTab(ts2);
		radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				Log.d("checked info ---->", checkedId + "");
				switch(checkedId){
				case R.id.radio_button0:
					tmh.setCurrentTabByTag(TAB_HOME);
					break;
				case R.id.radio_button1:
					tmh.setCurrentTabByTag(TAB_MSG);
					break;
				case R.id.radio_button2:
					
					break;
				
				}
			}
		});
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	
	}

	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
	}
   
}

	
